package cn.leelei.spring.service.impl;

import java.math.BigDecimal;

import org.springframework.stereotype.Service;

import cn.leelei.spring.service.IPayService;
/**
 * 实现支付方式的类
 * @author Administrator
 *
 */
@Service("IPayByServiceImpl")
public class IPayByServiceImpl implements IPayService {
	/**
	 * 余额 Amount
	 */
	private static double Amount =1000000;
	/**
	 * 支付 金额 Pay
	 */
	private static double Pay =1000000;
	
	

	public String PayByPoint(double integral) {
		BigDecimal bd = new BigDecimal(Pay);
		if(bd.subtract(new BigDecimal(integral)).compareTo(BigDecimal.ZERO) >=0){
			Pay = bd.subtract(new BigDecimal(integral)).floatValue();
			return "success";
		}else{
		return "fail";
		}
	}

	public String PayByRMB(double money) {
		BigDecimal bd = new BigDecimal(Pay);
		if(bd.subtract(new BigDecimal(money)).compareTo(BigDecimal.ZERO) >=0){
			Pay = bd.subtract(new BigDecimal(money)).floatValue();
			return "success";
		}else{
		return "fail";
		}
	}

	public static double getAmount() {
		return Amount;
	}

	public static void setAmount(double amount) {
		Amount = amount;
	}
}

